import type { Equal, Expect } from "@type-challenges/utils";

// type Replace<
//   X extends string,
//   Y extends string,
//   Z extends string
// > = X extends `${infer R}${Y}`
//   ? `${R}${Z}`
//   : X extends `${Y}${infer R}`
//   ? `${Z}${R}`
//   : X;

type cases = [
  Expect<Equal<Replace<"foobar", "bar", "foo">, "foofoo">>,
  Expect<Equal<Replace<"foobarbar", "bar", "foo">, "foofoobar">>,
  Expect<Equal<Replace<"foobarbar", "", "foo">, "foobarbar">>,
  Expect<Equal<Replace<"foobarbar", "bar", "">, "foobar">>,
  Expect<Equal<Replace<"foobarbar", "bra", "foo">, "foobarbar">>,
  Expect<Equal<Replace<"", "", "">, "">>
];
